package com.zhoug.zmui3demo.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zhoug.zmui3.badge.ZMUIBadgeFrameLayout;
import com.zhoug.zmui3demo.R;

import androidx.appcompat.app.AppCompatActivity;

public class BadgeViewActivity extends AppCompatActivity {

    private TextView mTextView1;
    private TextView mTextView2;
    private ImageView mImageView;
    private LinearLayout mLinearLayout;
    private ZMUIBadgeFrameLayout mZMUIBadgeFrameLayout;

    private int badge=1;
    private ZMUIBadgeFrameLayout mZMUIBadgeFrameLayout3;
    private ZMUIBadgeFrameLayout mZMUIBadgeFrameLayout1;
    private ZMUIBadgeFrameLayout mZMUIBadgeFrameLayout2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_badge_view);
        findViews();


    }

    private void findViews() {
        mTextView1 = findViewById(R.id.textView1);
        mTextView2 = findViewById(R.id.textView2);
        mImageView = findViewById(R.id.imageView);
        mLinearLayout = findViewById(R.id.linearLayout);
        mZMUIBadgeFrameLayout = findViewById(R.id.ZMUIBadgeFrameLayout);
        mZMUIBadgeFrameLayout1 = findViewById(R.id.ZMUIBadgeFrameLayout1);
        mZMUIBadgeFrameLayout3 = findViewById(R.id.ZMUIBadgeFrameLayout3);
        mZMUIBadgeFrameLayout2 = findViewById(R.id.ZMUIBadgeFrameLayout2);
    }


    public void add(View view) {
        badge+=5;
        mZMUIBadgeFrameLayout.setBadge(badge);
        mZMUIBadgeFrameLayout1.setBadge(badge);
        mZMUIBadgeFrameLayout2.setBadge(badge);
        mZMUIBadgeFrameLayout3.setBadge(badge);
    }

    public void reduce(View view) {
        badge-=5;
        if(badge<=0){
            badge=0;
        }
        mZMUIBadgeFrameLayout.setBadge(badge);
        mZMUIBadgeFrameLayout1.setBadge(badge);
        mZMUIBadgeFrameLayout2.setBadge(badge);
        mZMUIBadgeFrameLayout3.setBadge(badge);

    }

}